/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Javabeans;


/**
 * @author Muhammed
 * 
 */
public class DatPoint implements Cloneable, Comparable{
    private String[] data;

    public DatPoint(String[] data){
        this.data=data;
    }

    /**
     * @return the data
     */
    public String[] getData() {
        return data;
    }

    /**
     * @param data the data to set
     */
    public void setData(String[] data) {
        this.data = data;
    }

    /**
     * @param index
     * @param value
     */
    public void setData(int index, String value){
        this.data[index]=value;
    }
    /**
     * @param index
     */
    public String getData(int index){
        return this.data[index];
    }
    public Object clone(){
        try{
            String[] data=this.data.clone();
          DatPoint cloned = (DatPoint)super.clone();
          cloned.setData(data);
          return cloned;
        }
        catch(CloneNotSupportedException e){
          System.out.println(e);
          return null;
        }
    }
    public String toString(){
        boolean isFirst=true;
        String temp="";
        for(String s:data){
            if(isFirst){
                temp+=s;
                isFirst=false;
            }else{
                temp+=", "+s;
            }
        }
        return temp;
    }

    public int compareTo(Object o) {
        if(o instanceof DatPoint){
            DatPoint other = (DatPoint)o;
            int count =0;
            for(String s:data){
                if((s.compareTo((other.getData())[count++]))!=0){
                    return -1;
                }
            }
            return 0;
        }
        return -1;
    }
}
